Passed
Push — master ( e1efef...d34f83 )
by
unknown
15:24
created

NodeForm.show   A

Complexity

Conditions 3

Size

Total Lines 17
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 13
c 0
b 0
f 0
dl 0
loc 17
rs 9.75
1
class NodeForm {
2
    /**
3
     * Show this form in a jQueryUI dialog
4
     *
5
     * @return {void}
6
     */
7
    show() {
8
        this.hasBeenOpened = true;
9
        this.$form.dialog({
10
            title: this.name,
11
            closeText: LANG.plugins.prosemirror.cancel,
0 ignored issues
show
Bug introduced by
The variable LANG seems to be never declared. If this is a global, consider adding a /** global: LANG */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
12
            width: 800,
13
            appendTo: '.dokuwiki',
14
            modal: true,
15
            open: () => {
16
                const TIMEOUT_TO_LOOK_SMOOTH = 50;
17
                window.setTimeout(() => {
18
                    // hack to ensure this dialog is in front of other open dialogs, e.g. the footnote dialog.
19
                    this.$form.dialog('moveToTop');
20
                }, TIMEOUT_TO_LOOK_SMOOTH);
21
            },
22
        });
23
    }
24
25
    /**
26
     * Hide this form/dialog
27
     *
28
     * @return {void}
29
     */
30
    hide() {
31
        if (this.hasBeenOpened) {
32
            this.$form.dialog('close');
33
        }
34
    }
35
36
    /**
37
     * Bind a callback to an event on the form
38
     *
39
     * @param {string} eventName name of the event, can contain namespaces (e.g. click.myPlugin )
40
     * @param {function} callback the handler function to be attached to the event
41
     *
42
     * @return {void}
43
     */
44
    on(eventName, callback) {
45
        this.$form.on(eventName, callback);
46
    }
47
48
    /**
49
     * Remove a handler from an event
50
     *
51
     * @param {string} eventName name of the event, can contain namespaces (e.g. click.myPlugin )
52
     *
53
     * @return {void}
54
     */
55
    off(eventName) {
56
        this.$form.off(eventName);
57
    }
58
59
    destroy() {
60
        this.$form.remove();
61
    }
62
}
63
64
export default NodeForm;
65